package main

import (
	"fmt"

	ort "gitee.com/wb253/onnxruntime"
)

func main() {
	ort.SetSharedLibraryPath("/usr/local/lib/libonnxruntime.so")
	ort.InitializeEnvironment()
	defer ort.DestroyEnvironment()

	inputData := []float32{0.19473445415496826, 0.9139836430549622, 0.7043011784553528, 0.7685686945915222}
	inputShape := ort.NewShape(1, 1, 4)
	inputTensor, _ := ort.NewTensor(inputShape, inputData)
	defer inputTensor.Destroy()
	// This hypothetical network maps a 2x5 input -> 2x3x4 output.
	outputShape := ort.NewShape(1, 1, 2)
	outputTensor, _ := ort.NewEmptyTensor[float32](outputShape)
	defer outputTensor.Destroy()
	session, _ := ort.NewSession("./example_network.onnx",
		[]string{"1x4 Input Vector"}, []string{"1x2 Output Vector"}, nil)
	defer session.Destroy()
	// Calling Run() will run the network, reading the current contents of the
	// input tensors and modifying the contents of the output tensors.
	err := session.Predict([]ort.ArbitraryTensor{inputTensor}, []ort.ArbitraryTensor{outputTensor})

	if err != nil {
		fmt.Printf("err %s", err)
		return
	}
	fmt.Printf("output: %+v\r\n", outputTensor.GetData())
}
